function p = splitimage_MLR_GCK(input1,input2,train1,train2,w,scale1,scale2,sigma1,sigma2)

% x -> spectral vectors
% save classes
% y=x(2,:);

% delete first two (pixel number and classes)
% x(1:2,:)=[];


[d,n] =size(input1);
ntrain1 = sum(train1.^2);
ntrain2 = sum(train2.^2);
n1 = floor(n/80);
p = [];
for i = 1:79
    x1 = input1(:,((i-1)*n1+1):n1*i);
    nx1 = sum(x1.^2);
    [X1,Z1] = meshgrid(nx1,ntrain1);
    dist1 = Z1-2*train1'*x1+X1;
    K1=exp(-dist1/2/scale1/sigma1^2);
    
    x1 = input2(:,((i-1)*n1+1):n1*i);
    nx1 = sum(x1.^2);
    [X1,Z1] = meshgrid(nx1,ntrain2);
    dist1 = Z1-2*train2'*x1+X1;
    K2=exp(-dist1/2/scale2/sigma2^2);
    
    K1 = [ones(1,n1); K1;K2;];
    p1=mlogistic(w,K1);
    p = [p p1];
end

x1 = input1(:,(79*n1+1):n);
nx1 = sum(x1.^2);
[X1,Z1] = meshgrid(nx1,ntrain1);
dist1 = Z1-2*train1'*x1+X1;
K1=exp(-dist1/2/scale1/sigma1^2);

x1 = input2(:,(79*n1+1):n);
nx1 = sum(x1.^2);
[X1,Z1] = meshgrid(nx1,ntrain2);
dist1 = Z1-2*train2'*x1+X1;
K2=exp(-dist1/2/scale2/sigma2^2);

K1 = [ones(1,n-79*n1); K1;K2;];
    
p1=mlogistic(w,K1);
p = [p p1];